package Controller;

import Service.CarService;
import Service.LoginService;
import pojo.Car;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class CarController {
    private CarService carService;

    public CarController() throws Exception {
        carService = new CarService();
    }

    //查询所有数据展示在管理员窗口
    public List<Car> getAllCars() throws Exception {
        List<Car> carList = carService.getAllCars();
        return carList;
    }

    //根据id删除数据
    public void deleteCar(int carId) throws Exception {
        carService.deleteCar(carId);
    }
    //根据brand查询相关数据展示在管理员窗口
    public List<Car> getCarByBrand(String carBrand) throws Exception {
        List<Car> carList = carService.getCarByBrand(carBrand);
        return carList;
    }

    //管理员添加车辆信息
    public Boolean addCar(Car car) throws Exception {
        return carService.addCar(car);
    }

    //管理员取消订单，更新车辆状态为可租
    public void updateCarStatus(int carId) throws Exception {
        carService.updateCarStatus(carId);
    }

    public void updateCarById(int data_id, Car car) throws Exception {
        carService.updateCarById(data_id,car);
    }
}
